home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / assemblr / mslang / winclip / cb.asm next >
Assembly Source File  |  1992-11-03  |  6KB  |  148 lines

  1. ;  Copyright (c) 1991 Michael Kragl   All rights reserved.
  2. ;                     Compuserve: 75070,2113
  3. ;
  4. ;  MY_CLIPBRD
  5. ;  Copy Clipper-String to Microsoft Windows-Clipboard
  6. ;
  7. ;--------------------------------------------------------------------------
  8. ;       sample call from clipper:                                         |
  9. ;--------------------------------------------------------------------------
  10. ; |   external MY_CLIPBRD
  11. ; |   cliadr:="Teststring"
  12. ; |   ii=my_clipbrd(@cliadr)
  13. ; |
  14. ; |   do case
  15. ; |           case ii = 0
  16. ; |                   ii=my_clipbrd(@cliadr)      //sometimes it does'nt work for the 1st time
  17. ; |                   if ii = 0
  18. ; |                           ?"this function is only supported under Windows"
  19. ; |                           inkey(3)
  20. ; |                   else
  21. ; |                           ?"ok - 2"
  22. ; |                   endif
  23. ; |           case ii = 1
  24. ; |                   ?"ok"
  25. ; |           case ii = 2
  26. ; |                   ?"problem with EmptyClipboard"
  27. ; |                   inkey(3)
  28. ; |           case ii = 3
  29. ; |                   ?"problem with CloseClipboard"
  30. ; |                   inkey(3)
  31. ; |           case ii = 4
  32. ; |                   ?"problem with SetClipboardData"
  33. ; |                   inkey(3)
  34. ; |           otherwise
  35. ; |                   ?"????????????????"+str(ii)
  36. ; |                   inkey(3)
  37. ; |   endcase
  38. ;--------------------------------------------------------------------------
  39. PUBLIC               MY_CLIPBRD
  40. EXTRN                __RETNI:FAR        ;return integer
  41. EXTRN                __PARC:FAR         ;get character parameter
  42. EXTRN                __PARCLEN:FAR      ;get character parameter
  43. EXTRN                __PARNI:FAR        ;get character parameter
  44. ;--------------------------------------------------------------------------
  45. DGROUP GROUP _MY_DATA
  46. _MY_DATA SEGMENT 'DATA'
  47.     slen dw 0h
  48. _MY_DATA ENDS
  49. ;--------------------------------------------------------------------------
  50. _MY_CODE   SEGMENT 'CODE'
  51.              ASSUME cs:_MY_CODE, ds:DGROUP
  52.  
  53. MY_CLIPBRD PROC    FAR
  54. ;--------------------------------------------------------------------------
  55.      push    bp              ; save registers
  56.      mov     bp,sp
  57.      push    ds
  58.      push    es
  59.      push    si
  60.      push    di
  61. ;--------------------------------------------------------------------------
  62.      mov  ax,1700h            ; IdentifyWinOldApVersion
  63.      int  2fh
  64.      cmp  ax,2                ; Support Version 2?
  65.      je   OK                  ; if yes, then j ok
  66.      cmp ax,1700h             ; running under Windows?
  67.      je   NOWINDOW            ;
  68. ;--------------------------------------------------------------------------
  69. OK:
  70.      mov  ax,1701h            ; OpenClipboard
  71.      int  2fh
  72.      cmp  ax,0                ; ok?
  73.      jne EMPTYCB              ; error if 0
  74.      mov bx,2                 ;return  2  to clipper
  75.      jmp RETNC
  76. ;--------------------------------------------------------------------------
  77. EMPTYCB:
  78.      mov  ax,1702h            ; EmptyClipboard
  79.      int  2fh
  80.      cmp  ax,0                ; ok?
  81.      jne MOVEIT               ; error if 0
  82.      mov bx,2                 ;return  2  to clipper
  83.      jmp RETNC
  84. ;--------------------------------------------------------------------------
  85. MOVEIT:
  86.      mov ax,1
  87.      push ax
  88.      call __PARCLEN           ;find length of paramter -> ax
  89.      add SP,2
  90.      inc ax                   ;add 1 for terminating zero !! (this was hard to find for me)
  91.      mov slen,ax
  92. ;--------------------------------------------------------------------------
  93.      mov ax,1                 ;find address of parameter
  94.      push ax                  ;address in dx:ax
  95.      call __PARC
  96.      add sp,2
  97. ;--------------------------------------------------------------------------
  98.      mov  es,dx               ;String in ES:BX
  99.      mov  bx,ax               ;
  100.      mov dx,7                 ; CF_OEM_TEXT  for conversion to ansi
  101.      mov SI,0                 ;length in  SI:CX
  102.      mov cx,slen
  103.      mov ax,1703H             ;SetClipboardData
  104.      int 2fh
  105.      cmp  ax,0
  106.      jne COPYOK
  107.      mov bx,4                 ;return  4  to clipper
  108.      jmp RETNC
  109. ;--------------------------------------------------------------------------
  110. COPYOK:
  111.      mov  ax,1708h            ; CloseClipboard
  112.      int  2fh
  113.      cmp  ax,0
  114.      jne  CLOSOK              ; if 0 error
  115.      mov bx,3                 ;return  3  to clipper
  116.      jmp RETNC
  117. ;--------------------------------------------------------------------------
  118. CLOSOK:
  119.      mov bx,1                 ;return .t. to clipper
  120.      jmp RETNC1
  121. ;--------------------------------------------------------------------------
  122. NOWINDOW:
  123.      mov  bx,0
  124. ;--------------------------------------------------------------------------
  125. RETNC:
  126.      mov  ax,1708h            ; CloseClipboard
  127.      int  2fh                 ; int 2fh
  128. ;--------------------------------------------------------------------------
  129. RETNC1:
  130.      push bx
  131.      call __RETNI
  132.      add      sp,2
  133. ;--------------------------------------------------------------------------
  134.      pop     di               ; restore registers
  135.      pop     si
  136.      pop     es
  137.      pop     ds
  138.      pop     bp
  139.      cld
  140.  
  141.      ret
  142. ;-------------------------------------------------------------------
  143.  
  144. MY_CLIPBRD ENDP               ; end of procedure
  145.  
  146. _MY_CODE      ENDS            ; end of code segment
  147.               END
  148.